
<h2>Welcome!</h2>
<% unless session[:autentikoitu] %>
	<%= link_to "Rekister&ouml;idy", new_user_url %>
	
	<% form_for @user, :url=>session_url do |f|%>
	
		<p>
		<%= f.label :name %><br />
		<%= f.text_field :name %>
		</p>
		
		<p>
		<%= f.label :password %><br />
		<%= f.password_field :password %>
		</p>
		
		<p>
		<%= f.submit "Login" %>
		</p>
	<% end %>
<% else %>
	Hei, <%= link_to @user_now.name, edit_user_url %>!
	
	<p><%= link_to "All courses", courses_url %></p>
	
	Five latest courses:
	<p><ul>
		<% @courses.each do |course| %>
			<li /><%= link_to course.name, course_url(course) %>
		<% end %>
	</ul></p>
	
	
	<% if @user_now.admin %>
		<hr />
		
		<% form_for(@new_course) do |f|%>
			<p>
			<%= f.error_messages %>
			</p>
			
			<p>
			<%= f.submit "Create" %>
			</p>
		
			<p>
			<%= f.label :name %><br />
			<%= f.text_field :name %>
			</p>
			
			<p>
			<%= f.label :credits %><br />
			<%= f.text_field :credits %>
			</p>
			
			<p>
			<%= f.label :description %><br />
			<%= f.text_area :description %>
			</p>
			
			<p>
			<%= f.submit "Create" %>
			</p>
		<% end %>
	<% end %>
	
	<hr />
	
	<p>I want to <%= link_to "leave this place!", :action => "goodbye" %></p>
<% end %>